package com.tobe.phone.controller;

import com.tobe.phone.model.TSysUser;
import com.tobe.phone.service.ITSysUserService;
import com.tobe.phone.utils.Rs;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 
 *
 * @author chaoshen
 * @date 2020-09-18 10:56:27
 */
@Slf4j
@RestController
@RequestMapping("/tsysuser")
@Api(tags = "")
public class TSysUserController {
    @Autowired
    private ITSysUserService tSysUserService;


    /**
     * 查询
     */
    @ApiOperation(value = "查询")
    @GetMapping("/{id}")
    public Rs findUserById(@PathVariable Long id) {
        TSysUser model = tSysUserService.getById(id);
        return  Rs.ok("查询成功",model);
    }

    /**
     * 新增or更新
     */
    @ApiOperation(value = "保存")
    @PostMapping
    public Rs save(@RequestBody TSysUser tSysUser) {
        tSysUserService.saveOrUpdate(tSysUser);
        return Rs.ok("保存成功");
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除")
    @DeleteMapping("/{id}")
    public Rs delete(@PathVariable Long id) {
        tSysUserService.removeById(id);
        return Rs.ok("删除成功");
    }
}
